function showVideoMonitorDeviceSearch() {
	window.location.href = "showVideoMonitorDeviceSearch.do";
}

function ajaxFindVideoMonitorDeviceSearchList(currentPage,pageSize) {
	$.ajax({
		type : "post",
		url : "ajaxVideoMonitorDeviceSearchList.do",
		data : {
			deviceNum : $("#deviceNum").val(),
			currentPage:currentPage,
			pageSize:pageSize,
		},
		success : function(msg) {
			$("#listVideoMonitorDeviceBox").html(msg);
		}
	});
}

function ajaxShowVideoMonitorDeviceEdit(id){
	$.ajax({
		type:"post",
		url:"ajaxShowVideoMonitorDeviceEdit.do",
		data:{videoMonitorDeviceId:id},
		success:function(msg){
			$("#dialog").html(msg);
			$("#dialog").dialog({
				autoOpen: true,
				width: 740,
				title:$(".dialogtitle").attr("title"),
				modal: true,
				buttons: [
				          {
				        	  text: "保存",
				        	  click: function() {
				        		  ajaxSaveVideoMonitorDevice(this);
				        	  }
				          },
				          {
				        	  text: "关闭",
				        	  click: function() {
				        		  $(this).dialog( "close" );
				        	  }
				          }
				          ]
			});
		}
	});
}

function ajaxSaveVideoMonitorDevice(objDialog) {
	VideoMonitorDeviceValidate();
	if ($("#frmVideoMonitorDevice").valid()) {
		$(objDialog).dialog("close");
		var options ={
				type: "post",
				url : "ajaxSaveVideoMonitorDevice.do",
				success: function (msg) {
					clearInput("#sltVideoMonitorDevice");
					showMessageDialog("保存视频监控设备信息","视频监控设备信息保存成功。",null,dialogType.info);
					ajaxFindVideoMonitorDeviceSearchList();
				}
		};
		$("#frmVideoMonitorDevice").ajaxSubmit(options);
	}
}

function ajaxShowVideoMonitorDeviceView(id){
	$.ajax({
		type:"post",
		url:"ajaxShowVideoMonitorDeviceView.do",
		data:{VideoMonitorDeviceId:id},
		success:function(msg){
			$("#dialog").html(msg);
			$("#dialog").dialog({
				autoOpen: true,
				width: 740,
				title:$(".dialogtitle").attr("title"),
				modal: true,
				buttons : [ {
					text : "关闭",
					click : function() {
						$(this).dialog("close");
					}
				} ]
			});
		}
	});
}

function ajaxDeleteVideoMonitorDeviceById(id) {
	var VideoMonitorDeviceIds="";
	var sltSC = $("#listVideoMonitorDeviceList tbody input:checked").length;
	if(id==null){
		$("#listVideoMonitorDeviceList tbody input:checked").each(function(){ 
			VideoMonitorDeviceIds += $(this).val()+";";
		});
		if(sltSC == 0){
			showMessageDialog("提示","请选择一行或多行",null,dialogType.info);
			return;
		}else{
			VideoMonitorDeviceIds = VideoMonitorDeviceIds.substring(0, VideoMonitorDeviceIds.length-1);
		} 
	}else{
		VideoMonitorDeviceIds=id;
		sltSC = 1;
	}
	if( VideoMonitorDeviceIds!=null){
		showMessageDialog("删除视频监控设备信息","确定要删除所选“"+sltSC+"”条视频监控设备信息记录吗？",
				function () {
			$.ajax({     
				type:"post",
				url:"ajaxDeleteVideoMonitorDeviceByIds.do",
				data:{VideoMonitorDeviceIds:VideoMonitorDeviceIds},
				success:function(msg){
					ajaxFindVideoMonitorDeviceSearchList();
					showMessageDialog("提示","视频监控设备信息删除成功",null,dialogType.info);
				}
			});
		}
		,dialogType.warning);
	}
}

function VideoMonitorDeviceValidate(){
	$("#frmVideoMonitorDevice").validate({
		errorLabelContainer: $("#infoVideoMonitorDevice"),
		rules : {
		},
		messages : {
		},
		success: function(label) {
			label.html("&nbsp;");
		}
	});
}